using Microsoft.AspNetCore.Mvc;
using WL.Think.Abp.Dto;
using WL.Think.Abp.Services;

namespace WL.Think.Abp.Controllers;

/// <summary>
/// 分类控制器基类
/// </summary>
/// <typeparam name="TAppService">分类业务服务</typeparam>
/// <typeparam name="TGetOutputDto">分类实体对应DTO</typeparam>
/// <typeparam name="TGetListInput">分页DTO</typeparam>
/// <typeparam name="TCreateInput">创建DTO</typeparam>
/// <typeparam name="TUpdateInput">更新DTO</typeparam>
public abstract class BaseCategoryController<TAppService, TGetOutputDto, TGetListInput, TCreateInput, TUpdateInput> :
    AppControllerBase<TAppService, TGetOutputDto, TGetListInput, TCreateInput, TUpdateInput>
    where TAppService : IBaseCategoryAppService<TGetOutputDto, TGetListInput, TCreateInput, TUpdateInput>
    where TGetOutputDto : BaseCategoryDto<TGetOutputDto>
    where TGetListInput : BasePagedDto
    where TCreateInput : BaseCategoryCreateUpdateDto
    where TUpdateInput : BaseCategoryCreateUpdateDto
{
    protected BaseCategoryController(TAppService appService) : base(appService)
    {
    }

    /// <summary>
    /// 获取分类树
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet("tree")]
    public Task<List<TGetOutputDto>> GetTreeAsync([FromQuery] Guid? id = null)
    {
        return AppService.GetTreeAsync(id);
    }

    /// <summary>
    /// 获取启用的分类
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet("tree-active")]
    public Task<List<TGetOutputDto>> GetActiveTreeAsync(Guid? id = null)
    {
        return AppService.GetActiveTreeAsync(id);
    }

    /// <summary>
    /// 移动分类
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("move")]
    public Task MoveAsync([FromBody] BaseCategoryMoveDto input)
    {
        return AppService.MoveAsync(input);
    }
}

/// <summary>
/// 分类控制器基类
/// </summary>
/// <typeparam name="TAppService">分类业务服务</typeparam>
/// <typeparam name="TGetOutputDto">分类实体对应DTO</typeparam>
public abstract class BaseCategoryController<TAppService, TGetOutputDto, TGetListInput, TCreateInput> :
    BaseCategoryController<TAppService, TGetOutputDto, TGetListInput, TCreateInput, TCreateInput>
    where TAppService : IBaseCategoryAppService<TGetOutputDto, TGetListInput, TCreateInput>
    where TGetOutputDto : BaseCategoryDto<TGetOutputDto>
    where TGetListInput: BasePagedDto
    where TCreateInput : BaseCategoryCreateUpdateDto
{
    protected BaseCategoryController(TAppService appService) : base(appService)
    {
    }
}

/// <summary>
/// 分类控制器基类
/// </summary>
/// <typeparam name="TAppService">分类业务服务</typeparam>
/// <typeparam name="TGetOutputDto">分类实体对应DTO</typeparam>
public abstract class BaseCategoryController<TAppService, TGetOutputDto, TCreateInput> :
    BaseCategoryController<TAppService, TGetOutputDto, BasePagedDto, TCreateInput>
    where TAppService : IBaseCategoryAppService<TGetOutputDto, TCreateInput>
    where TGetOutputDto : BaseCategoryDto<TGetOutputDto>
    where TCreateInput: BaseCategoryCreateUpdateDto
{
    protected BaseCategoryController(TAppService appService) : base(appService)
    {
    }
}

/// <summary>
/// 分类控制器基类
/// </summary>
/// <typeparam name="TAppService">分类业务服务</typeparam>
/// <typeparam name="TGetOutputDto">分类实体对应DTO</typeparam>
public abstract class BaseCategoryController<TAppService, TGetOutputDto> :
    BaseCategoryController<TAppService, TGetOutputDto, BaseCategoryCreateUpdateDto>
    where TAppService : IBaseCategoryAppService<TGetOutputDto>
    where TGetOutputDto : BaseCategoryDto<TGetOutputDto>
{
    protected BaseCategoryController(TAppService appService) : base(appService)
    {
    }
}
